<!DOCTYPE html>
<!--
  ~ Copyright (C) 2018 guomw.Inc. All rights reserved.
  ~ 项目名称： mysite
  ~ 文件名称： list.html
  ~ Date：18-10-15 下午3:33
  ~ Author: guomw
  -->

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/head::head('修改报告')">
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <!--search-->
    <form role="form" class="search-panel" th:object="${report}">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content p-m no-borders">
                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">编码：</label>
                            <input type="text" class="form-control input-sm mb10" id="code" name="code"
                                   th:value="${report.code}" th:if="${report.id>0}" disabled/>

                            <input type="text" class="form-control input-sm mb10" id="code" name="code"
                                   th:value="${report.code}" th:if="${report.id==0}"/>
                        </div>


                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">版本号：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="version" name="version"
                                   th:value="${report.version}" th:if="${report.id>0}" disabled/>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="version" name="version"
                                   th:value="${report.version}" th:if="${report.id==0}"/>
                        </div>


                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">名称：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="name" name="name"
                                   th:value="${report.name}" style="width: 800px;"/>
                        </div>


                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">样本类型：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="sampleType"
                                   name="sampleType"
                                   th:value="${report.sampleType}"/>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">样本量：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="sampleAmount"
                                   name="sampleAmount"
                                   th:value="${report.sampleAmount}"/>
                        </div>


                        <p style="height: 8px;"></p>
                        <div class="form-inline ">
                            <label class="control-label">样式模板：</label>
                            <select class="form-control input-sm mb10 fa-mobile" id="template"
                                    name="template">
                                <option th:value="template1" th:text="模板1"></option>
                            </select>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">检测结果正常提示：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="checkResultNormalTip"
                                   name="checkResultNormalTip" th:value="${report.checkResultNormalTip}"
                                   style="width: 800px;"/>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">检测结果不正常提示：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="checkResultAbnormalTip"
                                   name="checkResultAbnormalTip" th:value="${report.checkResultAbnormalTip}"
                                   style="width: 800px;"/>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">检测结果正常建议：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="checkResultSuggest"
                                   name="checkResultSuggest" th:value="${report.checkResultSuggest}"
                                   style="width: 800px;"/>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">检测结果不正常建议：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile"
                                   id="checkResultAbnormalSuggest"
                                   name="checkResultAbnormalSuggest" th:value="${report.checkResultAbnormalSuggest}"
                                   style="width: 800px;"/>
                        </div>


                        <p style="height: 8px;display: none"></p>
                        <div class="form-inline" style="display: none">
                            <label class="control-label">封面：</label>
                            <div id="cover" name="cover" class="form-control input-sm mb10 fa-mobile"
                                 th:utext="${report.cover}"></div>
                        </div>
                        <!--<span style="color: red;">标签说明： <br>个人基本信息标签: {个人基本信息}<br> 检测结果标签: {检测结果标签} <br>请在报告内容中适当位置插入标签，系统会做替换处理</span>-->


                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">特别说明：</label>
                            <div id="special" name="special" class="form-control input-sm mb10 fa-mobile"
                                 th:utext="${report.special}"></div>
                        </div>


                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">检测的科学原理：</label>
                            <div id="theory" name="theory" class="form-control input-sm mb10 fa-mobile"
                                 th:utext="${report.theory}"></div>
                        </div>


                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">疾病概览：</label>
                            <div id="overview" name="overview" class="form-control input-sm mb10 fa-mobile"
                                 th:utext="${report.overview}"></div>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">参考文献：</label>
                            <div id="reference" name="reference" class="form-control input-sm mb10 fa-mobile"
                                 th:utext="${report.reference}"></div>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <button type="button" class="btn btn-success" onclick="uploadReport()">保存模板</button>
                            <input type="hidden" id="btnId" name="btnId" th:value="${report.id}"/>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->

</div>

<footer th:include="/common/footer::js"/>
<script charset="utf-8" src="richText/kindeditor-min.js" th:src="@{/resource/js/kindeditor/kindeditor-min.js}"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var cover = null;
    var special = null;
    var theory = null;
    var overview = null;
    var reference = null;
    $(function () {
        KindEditor.ready(function (K) {
            cover = K.create('#cover', {
                resizeType: '0',
                width: '800px',
                height: '300px',
                uploadJson: 'editor/fileUpload',
                afterBlur: function () {
                    this.sync();
                }
            });

            special = K.create('#special', {
                resizeType: '0',
                width: '800px',
                height: '300px',
                uploadJson: 'editor/fileUpload',
                afterBlur: function () {
                    this.sync();
                }
            });

            theory = K.create('#theory', {
                resizeType: '0',
                width: '800px',
                height: '300px',
                uploadJson: 'editor/fileUpload',
                afterBlur: function () {
                    this.sync();
                }
            });

            overview = K.create('#overview', {
                resizeType: '0',
                width: '800px',
                height: '300px',
                uploadJson: 'editor/fileUpload',
                afterBlur: function () {
                    this.sync();
                }
            });

            reference = K.create('#reference', {
                resizeType: '0',
                width: '800px',
                height: '300px',
                uploadJson: 'editor/fileUpload',
                afterBlur: function () {
                    this.sync();
                }
            });


        });

    })

</script>
<script>
    function uploadReport() {
        var code = $("#code").val();
        if (code == "") {
            swal("请输入编码", "", "warning")
            return;
        }
        var version = $("#version").val();
        if (version == "") {
            swal("请输入编码", "", "warning")
            return;
        }
        var params = {
            id: $("#btnId").val(),
            code: $("#code").val(),
            version: $("#version").val(),
            name: $("#name").val(),
            template: $("#template").val(),
            cover: cover.html(),
            special: special.html(),
            theory: theory.html(),
            overview: overview.html(),
            reference: reference.html(),
            checkResultNormalTip: $("#checkResultNormalTip").val(),
            checkResultAbnormalTip: $("#checkResultAbnormalTip").val(),
            checkResultSuggest: $("#checkResultSuggest").val(),
            checkResultAbnormalSuggest: $("#checkResultAbnormalSuggest").val(),
            sampleAmount: $("#sampleAmount").val(),
            sampleType: $("#sampleType").val(),

        };

        hotUtil.loading.show();
        hotUtil.ajaxCall("/report/save", params, function (ret) {
            hotUtil.loading.close();
            if (ret.resultCode == 1) {
                swal("保存报告成功", "", "success");
                window.location.href = "/report/list";
            } else {
                swal("保存报告失败", "", "warning")
            }
        });
    }


</script>
</body>
</html>
